<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/_fragments::head(~{::title})">
    <meta charset="UTF-8">
    <title>博客新增页</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/me.css">
    <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.min.css">
</head>
<body>

<!--导航-->
<nav th:replace="admin/_fragments::menu(1)" class="ui inverted semantic segment">
    <div class="ui container">
        <div class="ui inverted secondary menu">
            <h3 class="ui teal inverted header item">管理后台</h3>
            <a href="#" class="item">
                <i class="home icon"></i>
                博客
            </a>
            <a href="#" class="item">
                <i class="lightbulb icon"></i>
                分类
            </a>
            <a href="#" class="item">
                <i class="tags icon"></i>
                标签
            </a>
            <div class="right menu">
                <div class="ui dropdown item">
                    <div class="text">
                        <img src="https://picsum.photos/100/100" alt="" class="ui avatar image">
                        罗小宝
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</nav>

<!--中间部分-->
<div class="m-container m-padded-tb-large">
    <div class="ui container">
        <form id="blog-form" class="ui form" th:action="@{/admin/blogs}" method="post">
            <input type="hidden" name="published">
            <input type="hidden" name="id" th:value="${blog.id}">
            <div class="required field">
                <div class="ui left labeled input">
                    <div class="ui selection compact teal basic dropdown label">
                        <input type="hidden" value="原创" name="flag" th:value="${blog.flag}">
                        <i class="dropdown icon"></i>
                        <div class="text">原创</div>
                        <div class="menu">
                            <div class="item" data-value="原创">原创</div>
                            <div class="item" data-value="转载">转载</div>
                            <div class="item" data-value="翻译">翻译</div>
                        </div>
                    </div>
                    <input type="text" name="title" placeholder="标题" th:placeholder="${blog.title}">
                </div>
            </div>
            <div class="required field">
                <div id="md-content" style="z-index: 1 !important;">
                    <textarea placeholder="博客内容" name="content" style="display:none" th:text="${blog.content}">
                    </textarea>
                </div>
            </div>
            <div class="required field">
                <textarea placeholder="博客描述" name="description" th:placeholder="${blog.description}"></textarea>
            </div>
            <div class="two fields">
                <div class="required field">
                    <div class="ui left labeled action input">
                        <label class="ui compact teal basic label">分类</label>
                        <div class="ui fluid selection dropdown">
                            <input type="hidden" name="type.id"
                                   th:value="${blog.getTypeId()} != null ? ${blog.getTypeId()}">
                            <i class="dropdown icon"></i>
                            <div class="default text">分类</div>
                            <div class="menu">
                                <div class="item" th:each="type : ${types}" th:text="${type.name}"
                                     th:data-value="${type.id}" data-value="1">
                                    错误日志
                                </div>
                                <!--/*-->
                                <div class="item" data-value="认知升级">认知升级</div>
                                <div class="item" data-value="java">java</div>
                                <div class="item" data-value="mysql">mysql</div>
                                <!--*/-->
                            </div>
                        </div>
                    </div>
                </div>
                <div class="required field">
                    <div class="ui left labeled action input">
                        <label class="ui compact teal basic label">标签</label>
                        <div class="ui fluid selection dropdown">
                            <input type="hidden" name="tagIds" th:value="${blog.getTagIds()}">
                            <i class="dropdown icon"></i>
                            <div class="default text">标签</div>
                            <div class="menu">
                                <div class="item" th:each="tag : ${tags}" th:data-value="${tag.id}"
                                     th:text="${tag.name}" data-value="1">错误日志
                                </div>
                                <!--/*-->
                                <div class="item" data-value="认知升级">认知升级</div>
                                <div class="item" data-value="java">java</div>
                                <div class="item" data-value="mysql">mysql</div>
                                <!--*/-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="required field">
                <div class="ui left labeled action input">
                    <label class="ui compact teal basic label">首图</label>
                    <input type="text" name="firstPicture" placeholder="首图引用地址" th:placeholder="${blog.firstPicture}">
                </div>
            </div>
            <div class="inline fields">
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" name="recommend" id="recommend" th:checked="${blog.recommend}">
                        <label for="recommend">推荐</label>
                    </div>
                    <div class="ui  checkbox">
                        <input type="checkbox" name="shareStatement" id="shareStatement"
                               th:checked="${blog.shareStatement}">
                        <label for="shareStatement">转载声明</label>
                    </div>
                    <div class="ui  checkbox">
                        <input type="checkbox" name="appreciation" id="appreciation" th:checked="${blog.appreciation}">
                        <label for="appreciation">赞赏</label>
                    </div>
                    <div class="ui  checkbox">
                        <input type="checkbox" name="commentabled" id="commentabled" th:checked="${blog.commentabled}">
                        <label for="commentabled">评论</label>
                    </div>
                </div>
            </div>
            <div class="ui right aligned container">
                <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                <button type="button" id="save-btn" class="ui secondary button">保存</button>
                <button type="button" id="publish-btn" class="ui teal button">发布</button>
            </div>
        </form>
    </div>
</div>

<br>
<br>
<!--底部-->
<footer th:replace="_fragments::footer" class="ui inverted vertical segment m-padded-tb-massive">
    <div class="ui center aligned container">
        <div class="ui inverted divided grid">
            <div class="three wide column">
                <div class="inverted link list">
                    <img src="../static/img/wechat.jpg" alt="" class="ui rounded image">
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header">最新博客</h4>
                <div class="ui inverted link list">
                    <a href="" class="item">用户故事(Story)</a>
                    <a href="" class="item">用户故事(Story)</a>
                    <a href="" class="item">用户故事(Story)</a>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header">联系我</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">1944303766@qq.com</a>
                </div>
                <div class="ui inverted link list">
                    <a href="#" class="item">QQ:1944303766</a>
                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header">Blog</h4>
                <p>这是我的个人博客、会分享关于编程、写作、思考相关的任何内容，希望可以给来到这儿的人有所帮助...</p>
            </div>
        </div>
        <div class="ui inverted section divider"></div>
        <p>Copyright© 2020-2021</p>

    </div>
</footer>

</body>

<!--/*/<th:block th:replace="admin/_fragments::script">/*/-->
<script src="../../static/js/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.js"></script>
<script src="../../static/lib/editormd/editormd.min.js"></script>
<!--/*/</th:block>/*/-->
<script>

    var editor;
    $('.ui.dropdown')
        .dropdown()
    ;

    $(function () {
        editor = editormd("md-content", {
            width: "100%",
            height: 640,
            syncScrolling: "single",
            // path: "../../static/lib/editormd/lib/"
            path: "/lib/editormd/lib/"
        });
    });

    $("#save-btn").click(function () {
        $('[name="published"]').val(false);
        $('#blog-form').submit();
    });

    $("#publish-btn").click(function () {
        $('[name="published"]').val(true);
        $('#blog-form').submit();
    });


</script>
</html>